OpenWGA 7.6 - WebTML reference

WebTML tags » [All condition tags]

<tml:[All condition tags] istrue ="item | variable">

Purpose:

Tests if the value of the given item or WebTML variable is regarded "true"

Description:

Use this attribute to query frequently used flag variables in a speaking way. It tests all types of WebTML variables visible to the current code and the items on the current context document.

The following values are regarded "true":
  • A JavaScript or Java boolean value of true
  • The string "true"
  • A number of 1 or -1

Examples:

This example code sets a flag variable named "isAdmin" which tests access level and ACL roles if they match the needs for "being an administrator" of the application. The result of the test expression is a JavaScript boolean value that is stored to the variable:

<tml:script var="isAdmin" expression=" meta('db', 'accesslevel') == db().ACCESSLEVEL_MANAGER && meta('db', 'userroles').contains('#admin') "/>


If we do this right on the top of our WebTML page we can use the flag variable anywhere later where we want to show or hide something, based on the user being an administrator or not. This technique produces code that is better readable and executes faster than directly testing for access level and roles each time:

<tml:case itrue="isAdmin">
  ... Some administrator only controls ...
</tml:case>

<tml:case isfalse="isAdmin">
  <p>You are no administrator. Go away!</p>
</tml:case>